package com.yookey.study;

import android.content.Intent;
import android.text.TextUtils;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavCallback;
import com.alibaba.android.arouter.launcher.ARouter;
import com.base.commonlib.base.CBaseBarMvpActivity;
import com.base.commonlib.sp.SpUtil;
import com.base.commonlib.utils.ToastUtil;
import com.base.mine.config.RouteConfig;

/**
 * Created by weikailiang on 2020/4/7.
 */

public class ThirdPartyActivity extends CBaseBarMvpActivity{
    @Override
    protected int getLayoutResource() {
        return R.layout.activity_thirdparty;
    }

    @Override
    protected void init() {
        super.init();
        setBackNavigation();
        setBarTitle("第三方打开");
    }

    @Override
    protected void start() {
        Intent intent = getIntent();
        String data = intent.getDataString(); // 接收到网页传过来的数据：scheme://data/xxx
        String[] split = data.split("data/");
        String param = split[1]; // 获取到网页传过来的参数

        ToastUtil.show(param);

        if (TextUtils.isEmpty(SpUtil.getToken())){
            ARouter.getInstance().build(RouteConfig.ACTIVITIY_LOGIN).navigation(this, new NavCallback() {
                @Override
                public void onArrival(Postcard postcard) {
                    finish();
                }
            });
        }else {
            //主页
            ARouter.getInstance().build("/study/home").navigation(this, new NavCallback() {
                @Override
                public void onArrival(Postcard postcard) {
                    finish();
                }
            });
        }
    }
}
